package com.bgs.exception.eg;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Demo04TryWithResource {

	public static void main(String[] args) {
		String line;
		try (BufferedReader br = new BufferedReader(new FileReader("C:\\marmot\\tmp\\readtest.txt"))) {
			while ((line = br.readLine()) != null) {
				System.out.println(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		// br will be closed automatically
	}

}
